<template>
	<layout :loading="loading" curPage="staff" title="运维人员">
		
		<block slot="title">
			<authNav href="/pages/staff/staffEdit" url="/admin/staff/save" class="layui-btn layui-btn-sm">
				<i class="layui-icon layui-icon-add-1"></i>
				添加
			</authNav>
		</block>
		
		<conditions :list="conditonList" :conditions="conditions" @submit="submitSearch"></conditions>

		<div class="layui-form layui-border-box layui-table-view">

			<tableList :list="page.list" :canSelect="false">

				<block slot="head">
					<th>创建时间</th>
					<th>姓名</th>
					<th>所属公司</th>
					<th>手机号码</th>
					<th class="autoWidth">证件</th>
					<th>状态</th>
					<th>备注</th>
					<th>操作</th>
				</block>

				<block slot="body">

					<tr v-for="( x , index) in page.list" :key="index">
						<td>
							{{x.createTime}}
						</td>
						<td>
							{{x.name}}
						</td>
						<td>
							{{x.servicerName}}
						</td>
						<td>
							{{x.mobile}}
						</td>
						<td>
							<thumbImg :src="x.license"></thumbImg>
						</td>
						<td>
							{{x.statusStr}}
						</td>
						<td>
							{{x.refuseReason}}
						</td>
						<td>
							<authNav :href="'/pages/staff/staffEdit?id=' + x.id" url="/admin/staff/save" class="layui-btn layui-btn-xs">
								编辑
							</authNav>
							<authBtn :url="'/admin/staff/delete?id='+x.id" confirm="delete" class="layui-btn layui-btn-xs">
								删除
							</authBtn>
							<authBtn v-if="x.status == 2" :url="'/admin/staff/audit?isPass=1&id='+x.id" confirm="确认审核通过吗？" class="layui-btn layui-btn-xs">
								审核通过
							</authBtn>
							<auth v-if="x.status == 2" class="layui-btn layui-btn-xs" url="/admin/staff/audit">
								<view @tap="toShowDrawForm(x)" >
									审核拒绝
								</view>
							</auth>
						</td>
					</tr>

				</block>

			</tableList>
			
			<emptyTips :loading="loading" :list="page.list"></emptyTips>

			<paginate :page="page" @switchPage="switchPage" @changePageSize="changePageSize"></paginate>
			
			<alertForm action="/admin/staff/audit?isPass=0" :show="showDrawForm" @cancel="showDrawForm = false" @success="drawSuccess"
			 :width="500" title="审核拒绝">
				  
				 <inputGroup title="姓名" name="id" :value="drawData.name" :hiddenValue="drawData.id"></inputGroup> 
				  
				 <textareaGroup type="text" title="拒绝原因" name="reason|拒绝原因"></textareaGroup>
				
			</alertForm>
			
		</div>


	</layout>
</template>

<script>
	export default {
		data() {
			return {
				conditonList:[
					{title:"姓名",name:"ts.name",type:"varchar"},
					{title:"手机号码",name:"ts.mobile",type:"mobile"},
					{title:"身份证号",name:"ts.idcard",type:"char"},
					{title:"状态",name:"ts.status",type:"options",list:[]},
					{title:"所属公司",name:"tsr.name",type:"varchar"}
				],
				conditions: {},
				loading: true ,
				action: "/admin/staff/list",
				page: {
					pageNumber: 1,
					lastPage: true,
					totalPage: 1,
					list: [],
					totalRow: 0,
					pageSize: 10
				},
				showDrawForm : false ,
				drawData:{
					show : false 
				},
			}
		},
		
		onLoad:function(res){
			this.conditions = res || {} ;
		},

		onShow() {
			var that = this ;
			this.kit.getPage(this.action,function(res){
				that.conditonList[3].list = res.staffStatusList ;
			});
		},

		methods: {
			
			drawSuccess:function(e){
				this.showDrawForm = false ;
				this.switchPage();
			},
			
			toShowDrawForm:function(drawData){
				this.showDrawForm = true ;
				this.drawData = drawData ;
			},
			
			submitSearch:function(conditions){
				this.conditions = conditions ;
				this.switchPage(1);
			},
			
			switchPage: function(pageNumber) {
				this.page.pageNumber = pageNumber || this.page.pageNumber ;
				this.kit.getPage(this.action);
			},
			
			changePageSize: function(pageSize) {
				this.page.pageSize = pageSize;
				this.page.pageNumber = 1;
				this.kit.getPage(this.action);
			},
		}
	}
</script>